package com.joinway.extension.socket.serializer;

public class DualBytesShortSerializer implements ISegmentSerializer<Short> {

	@Override
	public Short deserialize(byte... bytes) {
		short low = (short)(0x00FF & bytes[0]);
		short high = (short)(0x00FF & bytes[1]);
		return (short)(high << 8 | low);
	}

	@Override
	public byte[] serialize(Short data) {
		return new byte[]{(byte)(0x00FF & data), (byte)((0xFF00 & data) >> 8)};
	}

}
